﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using Forget.Data;
namespace Forget.HRBLL.Model
{
    public partial class WorkingInfo
    {
        private static readonly string ADDWORKINGINFO = "HR_AddWorkingInfo";
        private static readonly string SELWORKINGINFO = "";

        #region properties
        [DataParam(32, SqlDbType.Int)]
        public int? WorkingID { get; set; }

        [DataParam(20, SqlDbType.NVarChar)]
        public string NumberID { get; set; }

        [DataParam(20, SqlDbType.DateTime)]
        public DateTime CardTime { get; set; }
        #endregion

        /// <summary>
        /// 添加打卡记录
        /// </summary>
        /// <param name="wInfo"></param>
        /// <returns></returns>
        public static bool AddWorkingInfo(WorkingInfo wInfo)
        {
            List<SqlParameter> parms = Convert<SqlParameter>.ObjectToParms(wInfo);
            try
            {
                if (DataAccess.ExecuteNonQuery(CommandType.StoredProcedure, ADDWORKINGINFO, parms.ToArray()) > 0)
                    return true;
            }
            catch (Exception ex)
            {
                Log.WriteLog("BU.AddWorkInfo", ex.Message, ex.StackTrace);
            }
            return false;
        }

        /// <summary>
        /// 返回workinginfo的集合
        /// </summary>
        /// <param name="wInfo"></param>
        /// <returns></returns>
        public static List<WorkingInfo> SelWorkingInfo(WorkingInfo wInfo)
        {
            List<WorkingInfo> wInfos = null;
            List<SqlParameter> parms = Convert<SqlParameter>.ObjectToParms(wInfo);
            try
            {
                DataTable table = DataAccess.ExecuteDataTable(CommandType.StoredProcedure, SELWORKINGINFO, parms.ToArray());
                wInfos = Convert<WorkingInfo>.DataConvertToObject(table);
            }
            catch (Exception ex)
            {
                Log.WriteLog("BU.SelWorkInfo", ex.Message, ex.StackTrace);
            }
            return wInfos;
        }
    }
}
